package com.ztom.beans.factory.support.reader

import com.ztom.beans.factory.support.registry.BeanDefinitionRegistry
import com.ztom.core.io.DefaultResourceLoader
import com.ztom.core.io.ResourceLoader

/**
 * @author ZhangTao
 */
abstract class AbstractBeanDefinitionReader : BeanDefinitionReader {

    private val registry: BeanDefinitionRegistry

    private val resourceLoader: ResourceLoader

    constructor(registry: BeanDefinitionRegistry) : this(registry, DefaultResourceLoader())

    constructor(registry: BeanDefinitionRegistry, resourceLoader: ResourceLoader) {
        this.registry = registry
        this.resourceLoader = resourceLoader
    }

    override fun getRegistry(): BeanDefinitionRegistry {
        return this.registry
    }

    override fun getResourceLoader(): ResourceLoader {
        return this.resourceLoader
    }

    override fun loadBeanDefinitions(locations: Array<String>) {
        locations.forEach { loadBeanDefinitions(it) }
    }
}